package com.lpf.www.common.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author lpf
 * @Date 2021/12/31 上午10:01
 * @ProjectName live-streaming-os
 * @Version 1.0
 * @Description:
 */
public class RequestResponseBox {
    private static final ThreadLocal<HttpServletRequest> request = new ThreadLocal<>();
    private static final ThreadLocal<HttpServletResponse> response = new ThreadLocal<>();

    public static HttpServletRequest getRequest() {
        return request.get();
    }

    public static void setRequest(HttpServletRequest request) {
        RequestResponseBox.request.set(request);
    }

    public static HttpServletResponse getResponse() {
        return response.get();
    }

    public static void setResponse(HttpServletResponse response) {
        RequestResponseBox.response.set(response);
    }

    public static void removeRequestResponse() {
        request.remove();
        response.remove();
    }
}
